{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "387d81ac",
   "metadata": {},
   "source": [
    "# FIR滤波器结构：直接型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c06355cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbgAAAEoCAYAAAAqrOTwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAhWUlEQVR4nO3df5RcdX3/8efLJcE9oSFAtpFEMeDhpJUmMbBNEwEbKRjlYE3TY6HYolUbFPrVIy2aFFBLraTQ0iMq1Gi0nNiCILiKKAQKkahJYdOERDiNPwl1IbiBhBgaJSTv7x/3DpkMM7t3dmd2Zu59Pc7Zc2bu/dz5fO5+svPOvff9+XwUEZiZmeXNy1rdADMzs2ZwgDMzs1xygDMzs1xygDMzs1xygDMzs1xygDNrU5J+S1Jb/I1KUqvbYFavtvjjMcszSUcMF6gkPSXpsIrNfcBvVyk7QVJX2XtJGlf2/nRJX62zjR+W9LYhiiyXdHo9n2nWapV/UGaFJenjwN8Ae8o2fzAiviJpDbA8Iu5Ky/4b8EfA88AvgY9GxJfTfY+k215IP+N3gO2SdqTvxwP9EXFRWT07I+KFNIhcAOwHXg78i6SfAuOASyLiWeDzwOsl7QOeBU4EbpTUD8wAvg78uuyciIiPD3Hec4G5wDVD/HqWA9+StDAidg9RzqxtOMCZHeozEbE0Y9mPRMS/SjoFuF/SXRGxIyJOKi8k6X+A34+Ipyo/QNJvkARJ0quw3cCjwD7gB8BE4PB0+wsAEXG+pGXAz4F1wBci4gOSzkuPOwDUM4PD3wHvjSFmfYiInZKuBf4a+Fgdn23WMr5FaTZKEbEBeAw4obRN0lJJmyRtAl4DrC69TwNRyV8A64FXAxuAncD3gXkR8RngR8DJEfHPEfGcpFmSLgLmAacDbwe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     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#libraries\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from scipy import signal\n",
    "\n",
    "#parameters of defference equation\n",
    "M0 = 11;M = np.arange(0,11,1);a = 1 #denominator\n",
    "b = np.power(0.9,M) #numerator\n",
    "\n",
    "#input signal\n",
    "N = 30;delta = signal.unit_impulse(N) #unit sample signal\n",
    "y = np.ones(N) #unit step signal\n",
    "\n",
    "#FIR dirfilter\n",
    "zi = signal.lfilter_zi(b,a)*0 #zero initial condition\n",
    "z1,_ = signal.lfilter(b,a,delta,zi=zi);z2,_ =signal.lfilter(b,a,y,zi=zi)\n",
    "\n",
    "#plot\n",
    "fig,axs = plt.subplots(2,1,constrained_layout=True)\n",
    "axs[0].stem(z1,basefmt=\"\");axs[1].stem(z2,basefmt=\"\")\n",
    "plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签\n",
    "axs[0].set_title('FIR直接型h(n)');axs[1].set_title('FIR直接型y(n)')\n",
    "plt.show();fig.savefig('./fir_dir_sequence.png',dpi=500)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dc0dae54",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
